class MyQueue {
    Stack<Integer> s1;
    Stack<Integer> s2;
    public MyQueue() {
        s1 = new Stack<>();//管理 ：进
        s2 = new Stack<>();//管理： 出(只要s2中还有元素，就可以独立出队列)
    }

    public void push(int x) {
        s1.push(x);
    }

    public int pop() {
        int peek = peek();
        s2.pop();
        return peek;
    }

    public int peek() {
        //不为空，直接取
        if(!s2.isEmpty()) {
            return s2.peek();
        }
        //没得取
        if(s1.isEmpty()) return -1;
        //s1中才有元素:全部放入s2
        while(!s1.isEmpty()) {
            s2.push(s1.pop());
        }
        return s2.peek();
    }

    public boolean empty() {
        return s1.isEmpty()&&s2.isEmpty();
    }
}

/**
 * Your MyQueue object will be instantiated and called as such:
 * MyQueue obj = new MyQueue();
 * obj.push(x);
 * int param_2 = obj.pop();
 * int param_3 = obj.peek();
 * boolean param_4 = obj.empty();
 */